﻿/*
 * QWine Queue Machine (Special build for Immigration Office)
 * Copyright (C) 2010 Wish Enterprise Development Team

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Contact Us:
 * E-Mail   : contact@wishenterprise.com
 * 
 * */

using System;
using System.Threading;
using System.Windows.Forms;
using QWModel.Properties;
using QWRepository;

namespace QWModel
{
    /// <summary>
    ///  QWButton : UserControl
    /// </summary>
    public sealed partial class QWButton : Label
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="QWButton"/> class.
        /// </summary>
        public QWButton()
        {
            InitializeComponent();

            BackgroundImage = Resources.rbutton_blue;
            Width = BackgroundImage.Width;
            Height = BackgroundImage.Height;
        }

        /// <summary>
        /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents.
        /// </summary>
        /// <value></value>
        /// <returns>true if the control adjusts its width to closely fit its contents; otherwise, false. The default is true.
        /// </returns>
        /// <PermissionSet>
        /// 	<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
        /// 	<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
        /// 	<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/>
        /// 	<IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
        /// </PermissionSet>
        public override bool AutoSize
        {
            get { return false; }
            set
            { base.AutoSize = false; }
        }

        /// <summary>
        /// Handles the MouseDown event of the QWButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void QWButton_MouseDown(object sender, MouseEventArgs e)
        {
            BackgroundImage = Resources.rbutton_orange;
        }

        /// <summary>
        /// Handles the MouseUp event of the QWButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void QWButton_MouseUp(object sender, MouseEventArgs e)
        {
            BackgroundImage = Resources.rbutton_blue;
        }

        /// <summary>
        /// Handles the Resize event of the QWButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void QWButton_Resize(object sender, EventArgs e)
        {
            Width = BackgroundImage.Width;
            Height = BackgroundImage.Height;
        }

        #region Nested type: DelegateThis

        /// <summary>
        /// DelegateThis
        /// </summary>
        private delegate void DelegateThis();

        #endregion

        /// <summary>
        /// Ts the beep.
        /// </summary>
        void TBeep()
        {
            WavPlayer.PlaySound("click");
        }
    }
}